package cn.edu.scau.cmil.shishuai.comprehensive.address.view;

import java.io.File;

import cn.edu.scau.cmil.shishuai.comprehensive.address.MainApp;
import cn.edu.scau.cmil.shishuai.comprehensive.address.model.Person;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.TextFieldTableCell;

public class secondMainController {
	private ObservableList<Person> StudentData = FXCollections.observableArrayList();

    public ObservableList<Person> getStudentData() {
        return StudentData;
    }
    public void addStudentData(Person person) {
    	this.StudentData.add(person);
    }
	@FXML
	private TableView<Person> tableView;
	@FXML
	private Label name;
	@FXML
	private Label lession;
	@FXML
	private TableColumn<Person, String> tc_s1;
	@FXML
	private TableColumn<Person, String> tc_s2;
	@FXML
	private TableColumn<Person, String> tc_s3;
	@FXML
	private TableColumn<Person, String> tc_s4;
	@FXML
	private TableColumn<Person, String> tc_s5;
	
	MainApp MainApp = new MainApp();
	@FXML
	public void initialize() {
		File personFile = MainApp.getPersonFilePath();
        if (personFile != null) {
        MainApp.loadPersonDataFromFile(personFile);
        } 
        
        LoginController user = new LoginController();
        name.setText(user.userperson.getName());
        
        tc_s1.setCellValueFactory(cellData -> cellData.getValue().Score1Property());
		tc_s2.setCellValueFactory(cellData -> cellData.getValue().Score2Property());
		tc_s3.setCellValueFactory(cellData -> cellData.getValue().Score3Property());
		tc_s4.setCellValueFactory(cellData -> cellData.getValue().Score4Property());
		tc_s5.setCellValueFactory(cellData -> cellData.getValue().Score5Property());


		StudentData.add(user.userperson);
		
		tableView.setItems(StudentData);
	}

}
